<#escape x as (x)!> <#include "basewithsidebar.ftl"/> <#macro title> ${config.blogTitle}-${post.title} </#macro> <#macro scripts>
<script type="text/javascript">
function checkvalue(form){
	if(form.username.value == ""){
		alert("用户名 不能为空。");
		return false;
	}
	if(form.content.value == ""){
		alert("评论 不能为空。");
		return false;
	}
	return true;
}
function keyboard_submit(form, event){
	if(event.ctrlKey&&event.keyCode==13){
		if(checkvalue(form)){
			form.submit();
		}
	}
}
</script>
</#macro> <#macro main> <#-- 文章区域 -->
<div class="post" id="${post.id}">
	<#if ! post.spined>
	<h2 class=title>
		<a href="/blog/post?action=view&postid=${post.id}">${post.title}</a>
	</h2>
	<div class="postinfo">
		${post.date?datetime} <#if post.tags?exists> |标签: <#list post.tags as tag>
		<a href="/blog/post?tag=${tag}">${tag}</a><#if tag_has_next>,</#if> </#list> </#if> <#if userService.userLoggedIn && userService.userAdmin> |
		<a href="/blog/post?action=delete&postid=${post.id}">删除</a> |
		<a href="/blog/post?action=edit&postid=${post.id}">编辑</a> </#if>
	</div>
	</#if>
	<div>
		${post.content}
	</div>

	<#if post.spined && userService.userLoggedIn && userService.userAdmin>
	<div class="postinfo">
		<a href="/blog/post?action=delete&postid=${post.id}">删除</a> |
		<a href="/blog/post?action=edit&postid=${post.id}">编辑</a>
	</div>
	</#if>
</div>

<#-- 评论区域 --> <#if post.isCommentEnabled() >
<div id="comments">
	<script type="text/javascript">
<!--
function addQuote(comment_id){
	var quoteComment = document.getElementById(comment_id).innerHTML; 
	quoteComment = quoteComment.replace(/<div.*?<\/div>/gi, "");
	quoteComment = quoteComment.replace("\r", "");
	quoteComment = quoteComment.replace("\n", "");
	quoteComment = quoteComment.replace(/<br.*?>/gi, "\r\n");
	quoteComment = quoteComment.replace("&gt;", ">");
	quoteComment = quoteComment.replace("&lt;", "<");
	quoteComment = quoteComment.replace("&nbsp;", " ");
	quoteComment = quoteComment.replace(/^\r?\n/, "");
	quoteComment = quoteComment.replace(/\r?\n$/, "");
	var replyText = document.getElementById('content');
	replyText.value+="[quote]"+quoteComment+"[/quote]\n";
	replyText.focus();
}
//-->
</script>
	<#list commentList as comment>
	<div class="comment">
		<div class="commenttitle" id="#c${comment.id}">
			<table width=100% CellSpacing=0 border=0 cellpadding=0>
				<tr>
					<td>
						${commentList?size - comment_index}楼 ${comment.date?datetime} | <#if comment.anonymous>游客：</#if>${comment.username?html} <#if comment.getHomepage()?exists> |
						<a href="${comment.homepage}" target="_blank">主页</a></#if> <#if userService.userLoggedIn && userService.userAdmin> <#if comment.email?exists> | ${comment.email?html}</#if> <#if comment.ip?exists> | ${comment.ip}</#if> </#if>
					</td>
					<td align=right>
						<a href="javascript:void(0)" onclick="addQuote('comment_${comment.id}')">引用</a> <#if userService.userLoggedIn > <#if !comment.anonymous && comment.author == user || userService.userAdmin >
						<a href="/blog/comment?action=delete&commentid=${comment.id}">删除</a> </#if> </#if>
					</td>
				</tr>
			</table>
		</div>
		<div class=commenbody id=comment_${comment.id}>
			${comment.content}
		</div>
	</div>
	</#list>

	<div class="comment">
		<form action="/blog/comment" method="post" onsubmit="return checkvalue(this);" onkeydown="keyboard_submit(this,event)">
			<input type=hidden name=action id=action value="new" />
			<#if userService.isUserLoggedIn()>
			<div class="description">
				发表评论:
			</div>
			<label for="username">
				用户:
			</label>
			<input name="username" id="username" disabled="disabled" value="${user.nickname}" />
			<#else>
			<div class="description">
				匿名发表评论 : （使用gmail账户
				<a href=${userService.createLoginURL(uri)} style="color: blue; text-decoration: underline">登录</a>）
			</div>
			<label for="username">
				游客:
			</label>
			<input name="username" id="username" maxlength=20 " />
			</#if> （必填）
			<br />
			<label for="email">
				邮箱:
			</label>
			<input type=text name="email" id="email" />
			（邮箱地址将不会公开）
			<br />
			<label for="homepage">
				主页:
			</label>
			<input type=text name="homepage" id="homepage" />
			<br />
			<textarea name="content" id="content" style="width: 80%; height: 100px; font-size: 12px;"></textarea>
			（必填）
			<input type="hidden" name="postid" id="postid" value="${post.id}" />
			<br />
			<#if !userService.isUserLoggedIn()>
			<label for="code">
				验证码:
			</label>
			<img src=/captcha style="display: inline;" />
			<input type=text name="code" id="code" size=5 />
			<br />
			</#if> <#if errmsg?exists>
			<div class="errmsg">
				${errmsg}
			</div>
			<br />
			</#if>
			<input type="submit" value="提交" />
			（快捷键 Ctrl+Enter）
		</form>

	</div>
</div>
</#if> </#macro> </#escape>
